﻿@{
    ViewBag.Title = "RptInsAccount";
}
@section scripts
{
    <script src="@Url.Content("~/Scripts/shared/share.js")" type="text/javascript"></script> 
    <script src="@Url.Content("~/Scripts/shared/shown.js")" type="text/javascript"></script> 
    <link href="~/Scripts/miniui/themes/default/medium-mode.css" rel="stylesheet" type="text/css" />      
    <script src="@Url.Content("~/Scripts/common/export.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/common/gridlayout.js")" type="text/javascript"></script>
}
    @Html.Partial("~/Views/Modular/ReportsToolbar.cshtml")
        <table style="margin-bottom:4px;">
            <tr>
                <td width ="70px" align="right">单据日期：</td>
                <td width ="310px">
                     @Html.Partial("~/Views/Modular/dxDateRange.cshtml")
                </td>
                <td width ="70px" align="right" >收款情况：</td>
                <td width ="200px">
                    <input id="comPayType" name ="FPayType" class="mini-combobox" style="width:150px;" 
                    showNullItem="false" required="true" value="0" allowInput="false" align="left" data ="dPayType"/>                          
                </td>
            </tr>
            <tr>
                <td width ="70px" align="right">单据编号：</td>
                <td width ="310px">
                    <input name="FBillNo" class="mini-textbox" style="width:207px;"/>   
                    <input id="comBillType" name ="FBillType" class="mini-combobox" style="width:90px;" 
                    showNullItem="false" required="true" value="0" allowInput="false" align="left" data ="dBillType"/>                     
                </td>
                <td width ="70px" align="right" >分店名称：</td>
                <td width ="200px">
                    @Html.Partial("~/Views/Delivery/LookupStockRelevant.cshtml") 
                </td>
            </tr>
        </table> 

    <div class="mini-fit">
     <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" 
                borderStyle="border:1;"  url="../Account/GetDawOutAccDetail" showSummaryRow="true" ondrawsummarycell="onDrawSummaryCell"
                allowCellSelect="true" onrowdblclick="editBill" allowCellEdit="true" fitColumns="false">
            <div property="columns">                                      
                <div field="FBillName" name="FBillName" width="80" headeralign="center" allowsort="true">单据类型</div>
                <div field="FDate" name="FDate" width="90" headeralign="center" allowsort="true" dateFormat="yyyy-MM-dd">单据日期</div>
                <div field="FBillNo" name="FBillNo" width="130" headeralign="center" allowsort="true">单据编号</div>
                <div field="FNumber" name="FNumber" width="80" headeralign="center" allowsort="true">分店编码</div>
                <div field="FName" name="FName" width="190" headeralign="center" allowsort="true">分店名称</div>      
                <div field="mFAmountOut" name="mFAmountOut" width="80" headeralign="center" align="right" allowsort="true" numberFormat="#,0.00">应收金额</div>          
                <div field="mFAmountGet" name="mFAmountGet" width="80" headeralign="center" align="right" allowsort="true" numberFormat="#,0.00">收款金额</div>
                <div field="mFAmountDis" name="mFAmountDis" width="80" headeralign="center" align="right" allowsort="true" numberFormat="#,0.00">折扣金额</div>                
                <div field="mFScBillNo" name="mFScBillNo" width="130" headeralign="center" allowsort="true">配送单号</div>
                <div field="mFRemark" name="mFRemark" width="230" headeralign="center" allowsort="true">摘要</div>                
            </div>
       </div>  
    </div>

<script>
    var dPayType = [{ "id": "0", "text": "全部" },
                     { "id": "1", "text": "已收款" },
                     { "id": "2", "text": "未收款" }]

    var dBillType = [{ "id": "0", "text": "全部" },
                     { "id": "1", "text": "配送单" },
                     { "id": "2", "text": "收款单" }]


    mini.parse();
    var grid = mini.get("datagrid1");
    var sumFields = "mFAmountOut,mFAmountGet,mFAmountDis";

    function FormShown() {
        var toDay = new Date();
        mini.getbyName("FDate1").setValue(toDay);
        mini.getbyName("FDate2").setValue(toDay);
    }
    $(function () {
        LoadData();
    });
    function LoadData() {
        var sSystemAppID = parent.window.getSystemAppID();
        var json = "[{";
        json = json + "'mSystemAppID':" + "'" + sSystemAppID + "',";
        json = json + "'mDate1':'" + mini.getbyName("FDate1").getFormValue() + "',";
        json = json + "'mDate2':'" + mini.getbyName("FDate2").getFormValue() + "',";
        json = json + "'mCustID':'" + mini.getbyName("FRStockID").getValue() + "',";
        json = json + "'mBillType':'" + mini.getbyName("FBillType").getValue() + "',";
        json = json + "'mPayType':'" + mini.getbyName("FPayType").getValue() + "',";
        json = json + "'mBillNo':'" + mini.getbyName("FBillNo").getValue() + "'}]";
        grid.load({ mydata: json });
        mExportDataUrl = grid.url;
        mExportDataJson = json;//导出
    }
    function search() {
        LoadData();
    }
    function printdata() {
        var grid = mini.get("datagrid1");
        var url = "../Report/PrintReport";
        mini.open({
            url: url,
            title: "打印", width: 1000, height: 700,
            onload: function () {
                var iframe = this.getIFrameEl();
                var NoneDisplayCol = [0,1];
                iframe.contentWindow.InitalPrint(grid, NoneDisplayCol, "分店往来账款");
            }
        });
    }

    function editBill() {
        var row = grid.getSelected();
        if (row) {
            if (row.FDataType == 12)
            {                
                parent.window.showTabByIdEx(85,'Delivery', '配送出库', '../Delivery/Delivery?datatype=12&billid=' + row.FSourceInterID);
            } else if (row.FDataType == 26) {                
                parent.window.showTabByIdEx(216,'DawOutGet', '配送收款单', '../Account/DawOutGet?datatype=26&billid=' + row.KInterID);
            }           
        }
    }

    function clearloca() {
        mini.getbyName("FRStockID").setValue('');
        mini.getbyName("FRStockID").setText('');
        mini.getbyName("FRStockName").setValue('');
        var nowDate = new Date();
        mini.getbyName("FDate1").setValue(nowDate);
        mini.getbyName("FDate2").setValue(nowDate);
        mini.getbyName("comdatasel").setValue(0);
    }
</script>

